<template></template>
<script setup name="singleLgon">

const { proxy } = getCurrentInstance()
const token = computed(() => {
  return proxy.$router.currentRoute._value.query.token
})

const loading = ref(false)
onMounted(() => {
  if (token.value) {
    single()
  } else {
    proxy.$router.push('/login')
  }
})
function single() {
  loading.value = true
  proxy.$store
    .dispatch('user/single', token.value)
    .then((res) => {
      if (res) {
        proxy.$router.push({
          path: '/',
        })
        loading.value = false
      } else {
        loading.value = false
      }
    })
    .catch((error) => {
      loading.value = false
      proxy.$message.error(error.msg)
    })
}
</script>
